/**
 * 
 */
package com.music.service.songs.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.music.service.songs.beans.Song;
import com.music.service.songs.constants.SongState;

/**
 * @author asanthan
 *
 */
public class SongMapper implements RowMapper {

	/* (non-Javadoc)
	 * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
	 */
	public Object mapRow(ResultSet pResultSet, int pArg1) throws SQLException {
		Song song = new Song();
		song.setSongId(pResultSet.getLong("song_id"));
		song.setOwnerId(pResultSet.getLong("created_member_id"));
		song.setSongName(pResultSet.getString("song_name"));
		song.setState(SongState.getSongState(pResultSet.getString("state")));
		song.setCreationDate(pResultSet.getDate("creation_date"));
		song.setLastUpdateDate(pResultSet.getDate("last_update_date"));
		
		return song;
	}

}
